package main

import "fmt"

func main() {
	// 声明,定义一个管道
	var intChan chan int
	intChan = make(chan int, 10)
	// 管道存值，它实际是个队列：先进先出
	intChan <- 12
	intChan <- 14
	intChan <- 15
	close(intChan) // 关闭后不能再存值
	// 管道取值
	fmt.Printf("管道的长度：%v,容量：%v\n", len(intChan), cap(intChan))
	fmt.Println(intChan)
	num := <-intChan
	fmt.Println(num)
	num = <-intChan
	fmt.Println(num)
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	num = <-intChan
	fmt.Println(num)
}
